<template>
  <el-card v-if="userInfo" class="profile-info-card">
    <template v-if="role === 'STUDENT'">
      <h2>我的信息</h2>
      <el-descriptions :column="1" border>
        <el-descriptions-item label="姓名">{{ userInfo.studentInfo?.name }}</el-descriptions-item>
        <el-descriptions-item label="性别">{{ userInfo.studentInfo?.gender === 1 ? '男' : '女' }}</el-descriptions-item>
        <el-descriptions-item label="出生日期">{{ userInfo.studentInfo?.birthDate }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ userInfo.studentInfo?.phone }}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{ userInfo.studentInfo?.email }}</el-descriptions-item>
        <el-descriptions-item label="学校">{{ userInfo.studentInfo?.school }}</el-descriptions-item>
        <el-descriptions-item label="专业">{{ userInfo.studentInfo?.major }}</el-descriptions-item>
        <el-descriptions-item label="学历">{{ userInfo.studentInfo?.degree }}</el-descriptions-item>
        <el-descriptions-item label="毕业时间">{{ userInfo.studentInfo?.graduateDate }}</el-descriptions-item>
        <el-descriptions-item label="项目经历">{{ userInfo.studentInfo?.projectExperience }}</el-descriptions-item>
        <el-descriptions-item label="获奖情况">{{ userInfo.studentInfo?.award }}</el-descriptions-item>
        <el-descriptions-item label="证书">{{ userInfo.studentInfo?.certificate }}</el-descriptions-item>
      </el-descriptions>
    </template>
    <template v-else-if="role === 'ENTERPRISE'">
      <h2>企业信息</h2>
      <el-descriptions :column="1" border>
        <el-descriptions-item label="企业名称">{{ userInfo.enterpriseInfo?.enterpriseName }}</el-descriptions-item>
        <el-descriptions-item label="所属行业">{{ userInfo.enterpriseInfo?.industry }}</el-descriptions-item>
        <el-descriptions-item label="企业规模">{{ userInfo.enterpriseInfo?.scale }}</el-descriptions-item>
        <el-descriptions-item label="企业地址">{{ userInfo.enterpriseInfo?.address }}</el-descriptions-item>
        <el-descriptions-item label="联系方式">{{ userInfo.enterpriseInfo?.contact }}</el-descriptions-item>
      </el-descriptions>
    </template>
    <template v-else>
      <h2>管理员信息</h2>
      <el-descriptions :column="1" border>
        <el-descriptions-item label="用户名">{{ userInfo.user?.username }}</el-descriptions-item>
        <el-descriptions-item label="角色">管理员</el-descriptions-item>
        <el-descriptions-item label="状态">{{ userInfo.user?.status }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ userInfo.user?.createTime }}</el-descriptions-item>
      </el-descriptions>
    </template>
  </el-card>
</template>
<script setup>
import { ref, onMounted, computed } from 'vue'
import axios from '@/utils/axios'
import { useUserStore } from '@/store/user'

const userStore = useUserStore()
const userInfo = ref(null)
const role = computed(() => userStore.role || userStore.userInfo?.role || 'STUDENT')

const fetchInfo = async () => {
  const res = await axios.get('/api/user/info')
  userInfo.value = res.data
}
onMounted(fetchInfo)
</script>
<style scoped>
.profile-info-card {
  max-width: 600px;
  margin: 40px auto;
  padding: 30px 20px;
}
</style> 